package de.jmda.gen.java.impl;

import javax.validation.constraints.NotNull;

import de.jmda.gen.java.FieldDeclarationGenerator;
import de.jmda.gen.java.DeclaredElementGenerator;
import de.jmda.gen.java.DeclaredFieldGenerator;

/**
 * @author roger.jmda@gmail.com
 */
public class DefaultFieldDeclarationGenerator
		extends AbstractDeclarationGenerator
		implements FieldDeclarationGenerator
{
	private DeclaredFieldGenerator declaredFieldGenerator;

	public DefaultFieldDeclarationGenerator()
  {
		this(null);
  }

	/**
	 * @param generator
	 */
	public DefaultFieldDeclarationGenerator(
			@NotNull DeclaredFieldGenerator generator)
  {
	  super();

	  if (generator == null)
	  {
	  	generator = new DefaultDeclaredInstanceFieldGenerator();
	  }

	  setDeclaredFieldGenerator(generator);

	  setComponentSeparator(System.lineSeparator());
  }

	@Override
  public DeclaredFieldGenerator getDeclaredFieldGenerator()
  {
	  return declaredFieldGenerator;
  }

	@Override
  public void setDeclaredFieldGenerator(DeclaredFieldGenerator generator)
  {
		if (generator == null)
		{
			return;
		}

		declaredFieldGenerator = generator;
  }

	@Override
  public DeclaredElementGenerator getDeclaredElementGenerator()
  {
	  return getDeclaredFieldGenerator();
  }
}